﻿using System;
using System.Collections.Generic;

namespace base31.Hub.Models
{
    /// <summary>
    /// Stores a set of known URL aliases for a particular feed.
    /// </summary>
    public class KnownFeedIdentity
    {
        public string FeedId { get; set; }
        public List<string> Topics { get; set; }
        public DateTime LastUpdate { get; set; }

        /// <summary>
        /// Creates a key for a KnownFeedIdentity.
        /// </summary>
        /// <param name="feedId">The feed's identity. For Atom this is the //feed/id element;
        /// for RSS it is the //rss/channel/link element. If for whatever reason
        /// the ID is missing, then the feed URL itself should be used.</param>
        /// <returns>Key instance for this feed identity.</returns>
        public string CreateKey(string feedId)
        {
            return null;
        }

        /// <summary>
        /// Updates a KnownFeedIdentity to have a topic URL mapping.
        /// </summary>
        /// <param name="feedId">The identity of the feed to update with the mapping.</param>
        /// <param name="topic">The topic URL to add to the feed's list of aliases.</param>
        /// <returns>The KnownFeedIdentity that has been created or updated.</returns>
        public KnownFeedIdentity Update(string feedId,
                                        string topic)
        {
            return null;
        }

        /// <summary>
        /// Updates a KnownFeedIdentity to no longer have a topic URL mapping.
        /// </summary>
        /// <param name="feedId">The identity of the feed to update with the mapping.</param>
        /// <param name="topic">The topic URL to remove from the feed's list of aliases.</param>
        /// <returns>The KnownFeedIdentity that has been updated or None if the mapping
        /// did not exist previously or has now been deleted because it has no
        /// active mappings.</returns>
        public KnownFeedIdentity Remove(string feedId,
                                        string topic)
        {
            return null;
        }

        /// <summary>
        /// Derives topic URL aliases from a set of topics by using feed IDs.
        /// If a topic URL has a KnownFeed entry but no valid feed_id or
        /// KnownFeedIdentity record, the input topic will be echoed in the output
        /// dictionary directly. This properly handles the case where the feed_id has
        /// not yet been recorded for the feed.
        /// </summary>
        /// <param name="topics">List of topic URLs.</param>
        /// <returns>Dictionary mapping input topic URLs to their full set of aliases,
        /// including the input topic URL.</returns>
        public Dictionary<string, string> DeriveAdditionalTopics(List<string> topics)
        {
            return null;
        }
    }
}